var data = {

  // 主题
  themes: [{ id: 0, name: '推荐', icon: 'camerafill', index: 0 }, { id: 1, name: '摄影', icon: 'camerafill', index: 0 }, { id: 2, name: '软件开发', icon: 'upstagefill', index: 1 }, { id: 4, name: '读书笔记', icon: 'clothesfill', index: 2 }, { id: 5, name: '转载', icon: 'clothesfill', index: 2 }],
  items: [{
    "images": [{
      "url": "http://ci.xiaohongshu.com/d4dc922a-7005-45a9-8cb3-741b8e103af7"
    }],
    frontImage: { url: 'http://ci.xiaohongshu.com/d4dc922a-7005-45a9-8cb3-741b8e103af7@r_640w_640h.jpg', width: '640', height: '640' },
    "themeIcon": "camerafill",
    "publishDate": "2016年8月8日",
    "themeId": "1",
    "isRecommend": "0",
    "id": "17",
    "hitsNum": 237,
    "title": "小狗的沧桑时光，那个迷一样的追风少年",
    "category": "摄影",
    "conmentNum": 993,
    "likeNum": 809,
    "tags": ["战旗东路", "黄昏"]
  }, {
    "images": [{
      "url": "http://ci.xiaohongshu.com/44987af4-6f5d-445d-8771-f93c7b176f06"
    }, {
      "url": "http://ci.xiaohongshu.com/2c01659c-b0df-4b7b-8c5e-88c8baf8e288"
    }, {
      "url": "http://ci.xiaohongshu.com/b1626a15-bff7-4885-abda-29df8d8ec90c"
    }],
      frontImage: { url: 'http://ci.xiaohongshu.com/44987af4-6f5d-445d-8771-f93c7b176f06@r_640w_640h.jpg', width: '200', height: '300' },
    "themeIcon": "camerafill",
    "publishDate": "2016年4月3日",
    "themeId": "1",
    "isRecommend": "1",
    "id": "16",
    "hitsNum": 804,
      "title": "生活、情感，简单点。就像简笔画一样🤓",
    "category": "摄影",
    "conmentNum": 198,
    "likeNum": 308,
    "tags": ["新津", "树木"]
  }, {
    "images": [{
      "url": "http://ci.xiaohongshu.com/9810b7ec-6217-4383-8d75-d8c92f008063"
    }],
      frontImage: { url: 'http://ci.xiaohongshu.com/9810b7ec-6217-4383-8d75-d8c92f008063@r_640w_640h.jpg', width: '200', height: '300' },
    "themeIcon": "camerafill",
    "publishDate": "2016年2月7日",
    "themeId": "1",
    "isRecommend": "0",
    "id": "15",
    "hitsNum": 306,
    "title": "时光里的碎片，有一块是金色的",
    "category": "摄影",
    "conmentNum": 63,
    "likeNum": 452,
    "tags": ["赛金", "黄昏"]
  }, {
    "images": [{
      "url": "http://ci.xiaohongshu.com/1728f4a4-0bc0-4b25-bc75-2a4e1b42fc9f"
    }],
      frontImage: { url: 'http://ci.xiaohongshu.com/1728f4a4-0bc0-4b25-bc75-2a4e1b42fc9f@r_640w_640h.jpg', width: '200', height: '300' },
    "themeIcon": "camerafill",
    "publishDate": "2015年11月15日",
    "themeId": "1",
    "isRecommend": "0",
    "id": "13",
    "hitsNum": 148,
    "title": "华西中医大一群老枪炮眼中景色，倒影果然吸人，犹如鱼游龙宫",
    "category": "摄影",
    "conmentNum": 723,
    "likeNum": 551,
    "tags": ["中医大", "建筑"]
  }, {
    "images": [{
      "url": "http://ci.xiaohongshu.com/76ec1cc1-6c70-4eda-8814-decd83079080"
    }, {
      "url": "http://ci.xiaohongshu.com/bd3201f8-ee5f-416a-b22c-d25e218cdaba"
    }, {
      "url": "http://ci.xiaohongshu.com/3c62c054-1016-4138-99b7-2914822bb322"
    }],
      frontImage: { url: 'http://ci.xiaohongshu.com/76ec1cc1-6c70-4eda-8814-decd83079080@r_640w_640h.jpg', width: '200', height: '300' },
    "themeIcon": "camerafill",
    "publishDate": "2015年6月6日",
    "themeId": "1",
    "isRecommend": "1",
    "id": "21",
    "hitsNum": 986,
    "title": "人像摆拍，初生牛犊装大神，鹅鹅鹅",
    "category": "摄影",
    "conmentNum": 396,
    "likeNum": 155,
    "tags": ["宜宾学院", "小师妹"]
  }, {
    "images": [{
      "url": "http://ci.xiaohongshu.com/5bac8017-10fe-41d4-b601-c13b0d220726"
    }, {
      "url": "http://ci.xiaohongshu.com/c6d5767d-716e-4bf0-a2be-c0ec64778c4d"
    }, {
      "url": "http://ci.xiaohongshu.com/e2df1e4e-65c8-409d-81f6-02e6eac08e34"
    }, {
      "url": "http://ci.xiaohongshu.com/10becd5b-e2a5-46a5-a327-71c597833777"
    }],
      frontImage: { url: 'http://ci.xiaohongshu.com/e2df1e4e-65c8-409d-81f6-02e6eac08e34@r_640w_640h.jpg', width: '200', height: '300' },
    "themeIcon": "camerafill",
    "publishDate": "2015年5月30日",
    "themeId": "1",
    "isRecommend": "0",
    "id": "20",
    "hitsNum": 316,
    "title": "是该为它留点什么",
    "category": "摄影",
    "conmentNum": 882,
    "likeNum": 212,
    "tags": ["宜宾学院", "小提琴"]
  }, {
    "images": [{
      "url": "http://ci.xiaohongshu.com/2efdf78f-cf8b-4cd0-bb9c-bbbfacd4f330"
    }],
      frontImage: { url: 'http://ci.xiaohongshu.com/2efdf78f-cf8b-4cd0-bb9c-bbbfacd4f330@r_640w_640h.jpg', width: '200', height: '300' },
    "themeIcon": "camerafill",
    "publishDate": "2015年8月1日",
    "themeId": "1",
    "isRecommend": "1",
    "id": "12",
    "hitsNum": 669,
    "title": "我只为你绽放在冬夜，你醒来的阳光",
    "category": "摄影",
    "conmentNum": 80,
    "likeNum": 293,
    "tags": ["龙泉驿", "树叶"]
  }, {
    "images": [{
      "url": "http://ci.xiaohongshu.com/5d3f726a-d644-46b6-807e-dba6a9786e21"
    }, {
      "url": "http://ci.xiaohongshu.com/5d3f726a-d644-46b6-807e-dba6a9786e21"
    }, {
      "url": "http://ci.xiaohongshu.com/5d3f726a-d644-46b6-807e-dba6a9786e21"
    }],
      frontImage: { url: 'http://ci.xiaohongshu.com/5d3f726a-d644-46b6-807e-dba6a9786e21@r_640w_640h.jpg', width: '200', height: '300' },
    "themeIcon": "camerafill",
    "publishDate": "2015年2月22日",
    "themeId": "1",
    "isRecommend": "0",
    "id": "18",
    "hitsNum": 23,
    "title": "虽为看狗，但很有成就感。舔狗舔到最后一无所有",
    "category": "摄影",
    "conmentNum": 41,
    "likeNum": 35,
    "tags": ["宜宾学院", "同学"]
  }, {
    "images": [{
      "url": "http://ci.xiaohongshu.com/6822b946-8ffd-4631-b641-0820484c416d"
    }],
      frontImage: { url: 'http://ci.xiaohongshu.com/6822b946-8ffd-4631-b641-0820484c416d@r_640w_640h.jpg', width: '200', height: '300' },
    "themeIcon": "camerafill",
    "publishDate": "2015年2月27日",
    "themeId": "1",
    "isRecommend": "1",
    "id": "11",
    "hitsNum": 315,
    "title": "它荡起了一层涟漪，整个世界都是你的",
    "category": "摄影",
    "conmentNum": 613,
    "likeNum": 70,
    "tags": ["龙泉驿", "雨"]
  }, {
    "images": [{
      "url": "http://ci.xiaohongshu.com/9f58f90c-3528-419c-9e4f-e7c4f647f831"
    }],
      frontImage: { url: 'http://ci.xiaohongshu.com/9f58f90c-3528-419c-9e4f-e7c4f647f831@r_640w_640h.jpg', width: '200', height: '300' },
    "themeIcon": "camerafill",
    "publishDate": "2014年11月12日",
    "themeId": "1",
    "isRecommend": "0",
    "id": "14",
    "hitsNum": 811,
    "title": "你瞅啥，瞅你咋得",
    "category": "摄影",
    "conmentNum": 254,
    "likeNum": 747,
    "tags": ["营门口", "狗"]
  }, {
    "images": [{
      "url": "http://ci.xiaohongshu.com/672482f8-8c54-41c8-9524-900c5a3e244d"
    }],
      frontImage: { url: 'http://ci.xiaohongshu.com/672482f8-8c54-41c8-9524-900c5a3e244d@r_640w_640h.jpg', width: '200', height: '300' },
    "themeIcon": "camerafill",
    "publishDate": "2014年10月4日",
    "themeId": "1",
    "isRecommend": "0",
    "id": "10",
    "hitsNum": 889,
    "title": "第一次抓拍，拍完之后对相机定格时间产生很大的吸引，当然也对自己的对焦和构图很是唾弃",
    "category": "摄影",
    "conmentNum": 536,
    "likeNum": 438,
    "tags": ["宜宾", "古镇"]
  }, {
    "images": [{
      "url": "http://ci.xiaohongshu.com/89df80a7-2a88-474c-9fd8-00fcd2cab006"
    }, {
      "url": "http://ci.xiaohongshu.com/ce23ff81-d7b1-450d-8ca4-c1442ee6a13a"
    }, {
      "url": "http://ci.xiaohongshu.com/ce23ff81-d7b1-450d-8ca4-c1442ee6a13a"
    }],
      frontImage: { url: 'http://ci.xiaohongshu.com/89df80a7-2a88-474c-9fd8-00fcd2cab006@r_640w_640h.jpg', width: '200', height: '300' },
    "themeIcon": "camerafill",
    "publishDate": "2014年8月15日",
    "themeId": "1",
    "isRecommend": "0",
    "id": "19",
    "hitsNum": 427,
    "title": "刚买完相机，第二天就去了解这个世界，全程P档见啥就拍",
    "category": "摄影",
    "conmentNum": 926,
    "likeNum": 860,
      "tags": ["若尔盖草原"]
  }, {
    "images": [{
      "url": "http://ci.xiaohongshu.com/e7b81e29-fa19-4b7f-b2f1-82b4be6996a4"
    }],
      frontImage: { url: 'http://ci.xiaohongshu.com/e7b81e29-fa19-4b7f-b2f1-82b4be6996a4@r_640w_640h.jpg', width: '200', height: '300' },
    "themeIcon": "upstagefill",
    "publishDate": "2019年9月30日",
    "themeId": "2",
    "isRecommend": "0",
    "id": 30,
    "hitsNum": 133,
    "title": "colorui搭建微信小程序",
    "category": "开发",
    "conmentNum": 703,
    "likeNum": 465,
    "tags": ["小程序", "colorui"]
  }, {
    "images": [{
      "url": "http://ci.xiaohongshu.com/b432ef4e-7dbe-4f90-ba94-af3f3f2f9a04"
    }],
      frontImage: { url: 'http://ci.xiaohongshu.com/b432ef4e-7dbe-4f90-ba94-af3f3f2f9a04@r_640w_640h.jpg', width: '200', height: '300' },
    "themeIcon": "upstagefill",
    "publishDate": "2019年9月30日",
    "themeId": "2",
    "isRecommend": "0",
    "id": 31,
    "hitsNum": 258,
    "title": "阿里云服务基于tomcat搭建web应用",
    "category": "开发",
    "conmentNum": 634,
    "likeNum": 480,
    "tags": ["阿里云", "服务器"]
  }, 
    {
      "images": [{
        "url": "http://ci.xiaohongshu.com/31cafa3e-c4b4-4958-87fa-787ee07a71b9"
      }],
      frontImage: { url: 'http://ci.xiaohongshu.com/31cafa3e-c4b4-4958-87fa-787ee07a71b9@r_640w_640h.jpg', width: '200', height: '300' },
      "themeIcon": "upstagefill",
      "publishDate": "2019年9月30日",
      "themeId": "5",
      "isRecommend": "0",
      "id": 991,
      "hitsNum": 258,
      "title": "阿里云服务基于tomcat搭建web应用",
      "category": "开发",
      "conmentNum": 634,
      "likeNum": 480,
      "tags": ["阿里云", "服务器"]
    },{
    "images": [{
      "url": "http://ci.xiaohongshu.com/0d56e6dd-2e53-4539-8a10-7fe42208bbcf"
    }],
      frontImage: { url: 'http://ci.xiaohongshu.com/0d56e6dd-2e53-4539-8a10-7fe42208bbcf@r_640w_640h.jpg', width: '200', height: '300' },
    "themeIcon": "clothesfill",
    "publishDate": "2019年7月30日",
    "themeId": "4",
    "isRecommend": "0",
    "id": 33,
    "hitsNum": 30,
    "title": "风骚律师.吉米如何风骚",
    "category": "开发",
    "conmentNum": 892,
    "likeNum": 119,
    "tags": ["电影"]
  },
    {
      "images": [{
        "url": "http://ci.xiaohongshu.com/56467a60-6be5-479e-94a9-135d1a82dce1"
      }, {
        "url": "http://ci.xiaohongshu.com/b2cfd6d6-5fc0-4c90-b157-334471e8b94a"
      }],
      frontImage: { url: 'http://ci.xiaohongshu.com/56467a60-6be5-479e-94a9-135d1a82dce1@r_640w_640h.jpg', width: '200', height: '300' },
      "themeIcon": "camerafill",
      "publishDate": "2019年10月4日",
      "themeId": "1",
      "isRecommend": "1",
      "id": "1",
      "hitsNum": 874,
      "title": "执剑走天涯，放汤不羁爱自由",
      "category": "摄影",
      "conmentNum": 381,
      "likeNum": 282,
      "tags": ["康定", "蓝天"]
    }, {
      "images": [{
        "url": "http://ci.xiaohongshu.com/f4ef2193-44fe-4b9a-8814-1b97ef033301"
      }, {
        "url": "http://ci.xiaohongshu.com/537204b8-2086-426a-9fd5-a08b4e7d41ce"
      }],
      frontImage: { url: 'http://ci.xiaohongshu.com/f4ef2193-44fe-4b9a-8814-1b97ef033301@r_640w_640h.jpg', width: '200', height: '300' },
      "themeIcon": "camerafill",
      "publishDate": "2019年10月5日",
      "themeId": "1",
      "isRecommend": "1",
      "id": "2",
      "hitsNum": 334,
      "title": "新都桥摄影的天堂，我只取那一朵",
      "category": "摄影",
      "conmentNum": 644,
      "likeNum": 463,
      "tags": ["新都桥", "格桑花"]
    }, {
      "images": [{
        "url": "http://ci.xiaohongshu.com/38f7a64d-9ff9-4904-9926-d49922789806"
      }],
      frontImage: { url: 'http://ci.xiaohongshu.com/38f7a64d-9ff9-4904-9926-d49922789806@r_640w_640h.jpg', width: '200', height: '300' },
      "themeIcon": "camerafill",
      "publishDate": "2018年8月12日",
      "themeId": "1",
      "isRecommend": "1",
      "id": "3",
      "hitsNum": 924,
      "title": "不知道这花叫啥",
      "category": "摄影",
      "conmentNum": 382,
      "likeNum": 300,
      "tags": ["河口湿地", "蓝天"]
    }, {
      "images": [{
        "url": "http://ci.xiaohongshu.com/2b6d1916-6289-45ad-b78a-9da962cce47e"
      }],
      frontImage: { url: 'http://ci.xiaohongshu.com/2b6d1916-6289-45ad-b78a-9da962cce47e@r_640w_640h.jpg', width: '200', height: '300' },
      "themeIcon": "camerafill",
      "publishDate": "2018年8月12日",
      "themeId": "1",
      "id": "4",
      "hitsNum": 150,
      "title": "安安静静，置身事外，看着平静的湖面发呆",
      "category": "摄影",
      "conmentNum": 512,
      "likeNum": 670,
      "tags": ["哈尔滨", "蓝天"]
    }]
}

function getData(pageNo, type) {
  var result = {};
  result.themes = data.themes;

  var itemType = type||data.themes[0].id;
  var contents = [];
  if (itemType == 0) {
    contents = data.items.filter(item => item.isRecommend == 1);
  } else {
    contents = data.items.filter(item => item.themeId == itemType);
  }

  var offset = (pageNo - 1) * 6;
  result.items = (offset + 6 >= contents.length) ? contents.slice(offset, contents.length) : contents.slice(offset, offset + 6);
  return result;
}

function getItemById(id) {
  var itemObject = {};
  data.items.forEach(function (item, index, array) {
    if (item.id == id) {
      itemObject = item;
    }
  })
  return itemObject;
}

module.exports = {
  getData: getData,
  getItemById: getItemById
}
